﻿using System;
using NUnit.Framework;

namespace SpellChecker.Tests
{
  [TestFixture]
  class TestSplitIntoWords
  {
    [Test]
    public void WithEmptyString()
    {
      var input = "";
      var result = SpellChecker.SplitIntoWords(input);

      Assert.That(result, Is.Empty);
    }


    [Test, ExpectedException(typeof(NullReferenceException))]
    public void WithNullString()
    {
      var input = (string)null;
      SpellChecker.SplitIntoWords(input);
    }

    [Test]
    public void OneWord()
    {
      var input = "Hallo";
      var result = SpellChecker.SplitIntoWords(input);
      var expected = new []{"Hallo"};

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void TwoWordsSeperatedBySemicolon()
    {
      var input = "Hallo;Stefan";
      var result = SpellChecker.SplitIntoWords(input);
      var expected = new[] { "Hallo", "Stefan" };

      Assert.That(result, Is.EqualTo(expected));
    }


    [Test]
    public void TwoWordsSeperatedByComma()
    {
      var input = "Hallo,Stefan";
      var result = SpellChecker.SplitIntoWords(input);
      var expected = new[] { "Hallo", "Stefan" };

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void TwoWordsSeperatedByWhiteSpace()
    {
      var input = "Hallo,Stefan";
      var result = SpellChecker.SplitIntoWords(input);
      var expected = new[] { "Hallo", "Stefan" };

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void TwoWordsSeperatedByAllKnownSeperators()
    {
      var input = "Hallo.,;!?'\" Stefan\n";
      var result = SpellChecker.SplitIntoWords(input);
      var expected = new[] { "Hallo", "Stefan" };

      Assert.That(result, Is.EqualTo(expected));
    }


  }
}
